package com.fr.data.core.define;

import com.fr.base.FCloneable;
import com.fr.base.StringUtils;
import com.fr.base.XMLable;
import com.fr.base.xml.XMLPrintWriter;
import com.fr.base.xml.XMLReadable;
import com.fr.base.xml.XMLableReader;
import com.fr.report.io.xml.ReportXMLUtils;
import java.util.ArrayList;
import java.util.List;

public class ReportDataDefinition extends TopDefinition
  implements FilterDefinition
{
  private static final long serialVersionUID = -7944306985328284088L;
  public static final String XML_TAG = "ReportDataDefinition";
  public static final int SERIES_IN_COLUMN = 0;
  public static final int SERIES_IN_ROW = 1;
  private boolean baseOnDataValueArea = false;
  private String seriesValueString = null;
  private String seriesNameString = null;
  private int seriesPos = 1;
  private String categoryNameString = null;
  private List seriesList = new ArrayList();

  public void setSeriesPos(int paramInt)
  {
    this.seriesPos = paramInt;
  }

  public int getSeriesPos()
  {
    return this.seriesPos;
  }

  public void setSeriesValueString(String paramString)
  {
    this.seriesValueString = paramString;
  }

  public String getSeriesValueString()
  {
    return this.seriesValueString;
  }

  public void setCategoryNameString(String paramString)
  {
    this.categoryNameString = paramString;
  }

  public String getCategoryNameString()
  {
    return this.categoryNameString;
  }

  public void setSeriesNameString(String paramString)
  {
    this.seriesNameString = paramString;
  }

  public String getSeriesNameString()
  {
    return this.seriesNameString;
  }

  public void setSeriesList(List paramList)
  {
    this.seriesList = paramList;
  }

  public List getSeriesList()
  {
    return this.seriesList;
  }

  public void setBaseOnDataValueArea(boolean paramBoolean)
  {
    this.baseOnDataValueArea = paramBoolean;
  }

  public boolean isBaseOnDataValueArea()
  {
    return this.baseOnDataValueArea;
  }

  public void readXML(XMLableReader paramXMLableReader)
  {
    super.readXML(paramXMLableReader);
    if (paramXMLableReader.isChildNode())
    {
      String str1;
      String str2 = paramXMLableReader.getTagName();
      if ((str2.equals("CategoryDefinition")) || (str2.equals("CategoryDefintion")))
      {
        if ((str1 = paramXMLableReader.getAttr("value")) != null)
          setCategoryNameString(str1);
      }
      else if (str2.equals("SeriesDefinition"))
      {
        if ((str1 = paramXMLableReader.getAttr("name")) != null)
          setSeriesNameString(str1);
        if ((str1 = paramXMLableReader.getAttr("value")) != null)
          setSeriesValueString(str1);
      }
      else if (str2.equals("SeriesPos"))
      {
        if ((str1 = paramXMLableReader.getAttr("value")) != null)
          setSeriesPos(Integer.parseInt(str1));
      }
      else if (str2.equals("BaseOn"))
      {
        if ((str1 = paramXMLableReader.getAttr("value")) != null)
          setBaseOnDataValueArea(Boolean.valueOf(str1).booleanValue());
      }
      else if (str2.equals("SeriesList"))
      {
        paramXMLableReader.readXMLObject(new XMLReadable(this)
        {
          private final ReportDataDefinition this$0;

          public void readXML()
          {
            if ((paramXMLableReader.isChildNode()) && ("SeriesEntry".equals(paramXMLableReader.getTagName())))
              this.this$0.getSeriesList().add(paramXMLableReader.readXMLObject(new ReportDataDefinition.SeriesEntry()));
          }
        });
      }
    }
  }

  public void writeXML(XMLPrintWriter paramXMLPrintWriter)
  {
    paramXMLPrintWriter.startTAG("ReportDataDefinition");
    if (StringUtils.isNotBlank(getCategoryNameString()))
      paramXMLPrintWriter.startTAG("CategoryDefinition").attr("value", getCategoryNameString()).end();
    if (StringUtils.isNotBlank(getSeriesValueString()))
    {
      paramXMLPrintWriter.startTAG("SeriesDefinition");
      if (StringUtils.isNotBlank(getSeriesNameString()))
        paramXMLPrintWriter.attr("name", getSeriesNameString());
      paramXMLPrintWriter.attr("value", getSeriesValueString());
      paramXMLPrintWriter.end();
    }
    paramXMLPrintWriter.startTAG("SeriesPos").attr("value", getSeriesPos()).end();
    paramXMLPrintWriter.startTAG("BaseOn").attr("value", isBaseOnDataValueArea()).end();
    if ((getSeriesList() != null) && (getSeriesList().size() > 0))
    {
      paramXMLPrintWriter.startTAG("SeriesList");
      for (int i = 0; i < getSeriesList().size(); ++i)
        ((SeriesEntry)getSeriesList().get(i)).writeXML(paramXMLPrintWriter);
      paramXMLPrintWriter.end();
    }
    super.writeXML(paramXMLPrintWriter);
    paramXMLPrintWriter.end();
  }

  public Object clone()
    throws CloneNotSupportedException
  {
    ReportDataDefinition localReportDataDefinition = (ReportDataDefinition)clone();
    localReportDataDefinition.setCategoryNameString(getCategoryNameString());
    localReportDataDefinition.setSeriesValueString(getSeriesValueString());
    localReportDataDefinition.setSeriesNameString(getSeriesNameString());
    localReportDataDefinition.setSeriesPos(getSeriesPos());
    return localReportDataDefinition;
  }

  public static class SeriesEntry
    implements XMLable
  {
    private String seriesName;
    private Object value;

    public SeriesEntry()
    {
    }

    public SeriesEntry(String paramString, Object paramObject)
    {
      this.seriesName = paramString;
      this.value = paramObject;
    }

    public void setSeriesName(String paramString)
    {
      this.seriesName = paramString;
    }

    public String getSeriesName()
    {
      return this.seriesName;
    }

    public void setValue(Object paramObject)
    {
      this.value = paramObject;
    }

    public Object getValue()
    {
      return this.value;
    }

    public void readXML(XMLableReader paramXMLableReader)
    {
      if (paramXMLableReader.isAttr())
      {
        String str;
        if ((str = paramXMLableReader.getAttr("name")) != null)
          this.seriesName = str;
      }
      if ((paramXMLableReader.isChildNode()) && ("O".equals(paramXMLableReader.getTagName())))
        this.value = ReportXMLUtils.readObject(paramXMLableReader);
    }

    public void writeXML(XMLPrintWriter paramXMLPrintWriter)
    {
      paramXMLPrintWriter.startTAG("SeriesEntry").attr("name", this.seriesName);
      ReportXMLUtils.writeObject(paramXMLPrintWriter, this.value);
      paramXMLPrintWriter.end();
    }

    public Object clone()
      throws CloneNotSupportedException
    {
      SeriesEntry localSeriesEntry = (SeriesEntry)super.clone();
      if (this.value instanceof FCloneable)
        localSeriesEntry.value = ((FCloneable)this.value).clone();
      return localSeriesEntry;
    }
  }
}